# Maintainer: David Runge <dvzrv@archlinux.org>

_name=crcmod
pkgname=python-crcmod
pkgver=1.7
pkgrel=6
pkgdesc="Module for generating objects that compute the Cyclic Redundancy Check (CRC)"
arch=(loong64 x86_64)
url="http://crcmod.sourceforge.net/"
license=(MIT)
depends=(
  glibc
  python
)
makedepends=(
  python-build
  python-installer
  python-setuptools
  python-wheel
)
source=(https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz)
sha512sums=('3c2f65004761c84f19d6ba95a0af74512108bad5007d9e20f8e684822e4196ce17073e58b47d2fa997e058e3d82782f3393458b6f0e86935418f38877d319a31')
b2sums=('542bdde18f4565f574a2746de5e1fcb10d015d5c89f3eba7a0c316a3e53eb5a895664e2f51e54dcbab7d2ee6f30055137f22498f44b6c27d40d0692ff9652813')

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name-$pkgver
  # install to temporary location, as importlib is used
  python -m installer --destdir=test_dir dist/*.whl
  export PYTHONPATH="test_dir/$site_packages:$PYTHONPATH"
  python test/test_crcmod.py
}

package() {
  cd "$_name-$pkgver"
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
}
